﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SPA_Prototype.Model
{
   public  class VIPManagement
    {
        private DatabaseDataSet _Dataset;
        private DatabaseDataSet.VIPManagementDataTable _DataTable;
        private DatabaseDataSetTableAdapters.VIPManagementTableAdapter  _Adt;

        public VIPManagement(DatabaseDataSet dt)
        {
            _Dataset = dt;
            _DataTable = _Dataset.VIPManagement;

            _Adt = new DatabaseDataSetTableAdapters.VIPManagementTableAdapter();

            LoadDB();
        }

        private int _MinAccount;
        public int MinAccount
        {
            get { return _MinAccount; }
            set
            {
                _MinAccount = value;
                _DataTable[0].MinVIPAccount = value;
            }
        }
        private int _MinVisitTimes;
        public int MinVisitTimes
        {
            get { return _MinVisitTimes; }
            set
            {
                _MinVisitTimes = value;
                _DataTable[0].MinVIPPoint = value;
            }
        }

        private void LoadDB()
        {
            _Adt.Fill(_DataTable);
            MinAccount = _DataTable[0].MinVIPAccount;
            MinVisitTimes = _DataTable[0].MinVIPPoint;
        }

        public void UpdateDB()
        {
            try
            {
                _Adt.Update(_DataTable);
                MessageBox.Show("Successful", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
